!> author: 左志华
!> date: 2022-07-23
module test_easy_math_m

    use testdrive, only: new_unittest, unittest_type, error_type, check
    use easy_math_m
    implicit none
    private

    public :: collect_easy_math

contains

    !> Collect all exported unit tests
    subroutine collect_easy_math(testsuite)
        !> Collection of tests
        type(unittest_type), allocatable, intent(out) :: testsuite(:)

        testsuite = [ &
                    new_unittest("PARA: sqrt_eps", test_sqrt_eps), &
                    new_unittest("PARA: Pi", test_Pi), &
                    new_unittest("FUNC: arange", test_arange) &
                    ]

    end subroutine collect_easy_math

    subroutine test_sqrt_eps(error)
        type(error_type), allocatable, intent(out) :: error
        call check(error, sqrt_eps, 1.4901161193847656E-008_8, more='sqrt_eps')
    end subroutine test_sqrt_eps

    subroutine test_Pi(error)
        type(error_type), allocatable, intent(out) :: error
        call check(error, Pi, 3.1415926535897931_8, more='Pi')
    end subroutine test_Pi

    subroutine test_arange(error)
        type(error_type), allocatable, intent(out) :: error
        call check(error, all(arange(0, 9) == [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]), more='arange(0, 9)')
    end subroutine test_arange

end module test_easy_math_m
